#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <list>
#include <vector>
#include "string.h"

#include "list.h"

using namespace std;

void test1()
{
	shr::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	l.push_back(4);

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;

	l.pop_back();
	l.pop_back();
	l.pop_back();
	//l.pop_back();
	//l.pop_back();

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;

	l.push_front(10);
	l.push_front(20);
	l.push_front(30);
	l.push_front(40);

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;

	l.pop_front();
	l.pop_front();
	l.pop_front();

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;
}

void test2()
{
	shr::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	l.push_back(4);
	l.push_back(5);

	auto it = l.begin();
	for ( ; it != l.end(); ++it)
	{
		if (*it == 3) {
			break;
		}
	}
	if (it != l.end())
	{
		l.erase(it);
	}
	l.insert(l.begin(), 50);
	l.insert(l.end(), 80);

	l.erase(l.begin());
	l.erase(--l.end());

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;
}

void test3()
{
	shr::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	l.push_back(4);
	l.push_back(5);

	shr::list<int> l2(l);
	for (auto e : l2) {
		cout << e << ' ';
	}
	cout << endl;

	l2.push_back(19);
	l2.push_back(29);
	l2.push_back(39);

	l.swap(l2);

	for (auto e : l) {
		cout << e << ' ';
	}
	cout << endl;

	for (auto e : l2) {
		cout << e << ' ';
	}
	cout << endl;
}

void test4()
{
	shr::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	l.push_back(4);
	l.push_back(5);

	shr::list<int>::reverse_iterator rit = l.rbegin();
	while (rit != l.rend())
	{
		cout << *rit << ' ';
		++rit;
	}
}

shr::list<int> func()
{
	shr::list<int> l;
	l.push_back(10);
	l.push_back(9);
	l.push_back(8);
	return l;
}

void test5()
{
	//shr::list<int> ret = func();
	shr::list<shr::string> l;
	l.push_back("hello world");
}

template<class T1, class T2>
struct myPair
{
	T1 _first;
	T2 _second;

	//myPair(T1 data1 = T1(), T2 data2 = T2())
	//	:_first(data1), _second(data2)
	//{ }

	myPair(T1 data1 = T1(), T2 data2 = T2())
		:_first(data1), _second(data2)
	{ }
};

void test6()
{
	shr::list<myPair<int, int>> l;
	l.emplace_back(1, 2);
	l.emplace_back(3, 4);
	l.emplace_back(5, 10);

	l.emplace_front(-2, -4);
	l.emplace_front(-9, -6);

	//std::list<myPair<int, int>> l;
	//l.emplace_back(1, 2);
	//l.emplace_back();
}

int main()
{
	//test1();
	//test2();
	//test3();
	//test4();
	//test5();
	test6();
	return 0;
}